package com.bhs.sansonglogistics.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;

public class BottomTypeDialog extends Dialog implements View.OnClickListener {

    private FrameLayout mFlClose;
    private TextView mTvBusinessLicense;
    private TextView mTvCircleFriends;

    public BottomTypeDialog(@NonNull Context context) {
        super(context, R.style.MyBottomDialogStyle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_bottom_type);
        Window window = getWindow();
        //底部弹出的Dialog
        window.setGravity(Gravity.BOTTOM);
        //设置动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams attributes = window.getAttributes();
        //保证按钮水平满屏
        attributes.width = ViewGroup.LayoutParams.MATCH_PARENT;
        attributes.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        //设置显示位置
        window.setAttributes(attributes); //将属性设置给窗体
        initView();
    }

    private void initView() {
        mFlClose = findViewById(R.id.fl_close);
        mTvBusinessLicense = findViewById(R.id.tv_business_license);
        mTvCircleFriends = findViewById(R.id.tv_circle_friends);
        mFlClose.setOnClickListener(this);
        mTvBusinessLicense.setOnClickListener(this);
        mTvCircleFriends.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        dismiss();
        listener.onClick(view);
    }

    private MyClickListener listener;

    public void setMyClickListener(@Nullable MyClickListener l) {
        this.listener = l;
    }
}
